class Solution
{
public:
    int majorityElement(vector<int>& nums)
    {
        int n = nums.size();
        unordered_map<int, int> mymap;
        int ans = 0;

        for (auto x : nums)
        {
            mymap[x]++;
            if (mymap[x] > n / 2)
                ans = x;
        }
        return ans;
    }
};